import request from "@/utils/request";

export const getRolesList = () => {
  return request({
    method: "GET",
    url: "/private/v1/roles",
  });
};

export const addRoles = (data) => {
  return request({
    method: "POST",
    url: "/private/v1/roles",
    data,
  });
};

export const getRolesId = (id) => {
  return request({
    method: "GET",
    url: "/private/v1/roles/" + id,
  });
};

export const editRoles = (id, data) => {
  return request({
    method: "PUT",
    url: "/private/v1/roles/" + id,
    data,
  });
};

export const delRolesId = (id) => {
  return request({
    method: "DELETE",
    url: "/private/v1/roles/" + id,
  });
};

export const delRolesByid = (RoId, RigId) => {
  return request({
    method: "DELETE",
    url: `/private/v1/roles/${RoId}/rights/` + RigId,
  });
};

export const getAllRightsList = () => {
  return request({
    method: "GET",
    url: "/private/v1/rights/tree",
  });
};

export const updateAllRights = (id, str) => {
  return request({
    method: "POST",
    url: `/private/v1/roles/${id}/rights`,
    data: {
      rids: str,
    },
  });
};
